using System;
using System.Collections.Generic;
using System.Text;

namespace Bludz
{
    class ResourceManager<ResourceType, Subclass> : Singleton<Subclass> where Subclass : new()
    {
        protected Dictionary<string, ResourceType> data;

        public ResourceManager()
        {
            data = new Dictionary<string, ResourceType>();
        }

        public bool hasResource(string name) {
            return data.ContainsKey(name);
        }

        public virtual ResourceType loadResource(string name)
        {
            return GameServer.get().content.Load<ResourceType>(name);
        }

        public ResourceType getResource(string name) {
            if (!hasResource(name))
                data[name] = loadResource(name);
            return data[name];
        }
    }
}
